package com.cn.zengzeng.spbzengzeng.singleton.dto3;

import com.cn.zengzeng.spbzengzeng.singleton.dto2.SingletonDemo;

/**
 * 静态内部类
 * @Author: ZhangZengZeng
 * @Date: 2023/3/18 15:58
 */
public class singletonDemo {



    private singletonDemo(){
    }

    public static singletonDemo getInstance(){
        return Inner.singletonDemo;
    }

    public static class Inner {
        private static singletonDemo singletonDemo = new singletonDemo() ;
    }

    public static void main (String[] args) {
        for(int i = 0;i < 10;i++) {
            new Thread(new Runnable() {
                @Override
                public void run () {
                    SingletonDemo instance = SingletonDemo.getInstance();
                    System.out.println("instance = " + instance);
                }
            }).start();
        }
    }
}
